﻿@model List<Question>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>试题信息</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.0/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
    <!--展示数据的主窗口-->
    <div class="container mt-5">
        <div class="row">
            <div class="col-md-12">
                <div class="card">
                    <div class="card-header bg-primary text-white">
                        <form asp-action="SltJump" asp-controller="Questions" class="my-4">
                            查找试题：<input type="text" class="text-black-50" name="question_content" />
                            <input type="submit" class="btn btn-warning edit-btn" value="查询" />
                        </form>
                    </div>
                    <div class="card-body">
                        <table class="table table-striped">
                            <thead>
                                <tr>

                                    <th>题目</th>
                                    <th>类型</th>
                                    <th>难度</th>
                                    <th>知识点</th>
                                    <th>答案</th>
                                    <th>操作</th>
                                </tr>
                            </thead>
                            <tbody>
                                @foreach (var question in Model)
                                {
                                    // 如果内容过长只展示前面的部分
                                    string displayContent = question.question_content.Length > 30
                                    ? question.question_content.Substring(0, 30) + "..."
                                    : question.question_content;

                                    string displayContent1 = question.answer.Length > 30
                                    ? question.answer.Substring(0, 30) + "..."
                                    : question.answer;

                                    <tr>

                                        <td>@displayContent</td>
                                        <td>@question.question_type</td>
                                        <td>@question.question_difficulty</td>
                                        <td>@question.kp_name</td>
                                        <td>@displayContent1</td>
                                        <td><form asp-action="Showone" asp-controller="Questions" method="post" class="my-4">
                                                <input type="hidden" name="question_id" value="@question.question_id" />
                                               
                                                <input type="submit" class="btn btn-danger delete-btn" value="查看">
                                            </form></td>
                                        <td>
                                            <form asp-action="DelSumbit" asp-controller="Questions" method="post" class="my-4">
                                                <input type="hidden" name="question_content" value="@question.question_content" />
                                                <input type="submit" class="btn btn-danger delete-btn" value="删除">
                                            </form>
                                        </td>
                                        <td>
                                            <form asp-action="UpdJump" asp-controller="Questions" class="my-4">
                                                <input type="hidden" name="question_id" value="@question.question_id" />
                                               
                                                <input type="submit" class="btn btn-warning edit-btn" name="question_id"value="修改">
                                            </form>
                                        </td>
                                    </tr>
                                }
                            </tbody>
                        </table>
                        <!-- Bootstrap 分页组件 -->
                        <nav aria-label="Page navigation example">
                            <ul class="pagination justify-content-center">
                                <li class="page-item"><a class="page-link" href="#">上一页</a></li>
                                <li class="page-item"><a class="page-link" href="#">1</a></li>
                                <li class="page-item"><a class="page-link" href="#">下一页</a></li>
                            </ul>
                        </nav>

                    </div>
                </div>
            </div>
        </div>
    </div>

</body>
</html>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.6.0/dist/js/bootstrap.bundle.min.js"></script>

<script>
    // 如果 TempData["Message"] 有内容，则显示一个 alert 对话框
    @if (TempData["Message"] != null)
    {
        <text>
            alert("@Html.Raw(TempData["Message"])");
        </text>
    }
</script>
